package com.start.shejimoshi.gongchang.jiandangongshangmoshi;

public class Factory1 {

    public static Fruits getFruits(Class c) {

        Fruits fruits = null;

        try {
            fruits = (Fruits) Class.forName(c.getName()).newInstance();
        } catch (InstantiationException e) {

            e.printStackTrace();
            System.out.println("不支持抽象类或接口");
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            System.out.println("没有足够权限，即不能访问私有对象");

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.out.println("类不存在");
        }

        return fruits;


    }


}
